# -*- coding:utf-8 -*-
#! python3

# FaceCat-Python
#Shanghai JuanJuanMao Information Technology Co., Ltd 

from facecat_objc import *

gPaint = FCPaint() #创建绘图对象

#加载示例
def loadUI():
	xml = """<?xml version="1.0" encoding="utf-8"?>
<html xmlns="facecat">
  <head>
  </head>
  <body>
    <div dock="fill" type="tab" selectedindex="0">
      <div name="TabPage" text="可视化生成" type="tabpage">
        <input type="radio" name="RadioButton" text="RadioButton" location="25,46" size="100,20" groupname="example" />
        <input type="radio" name="RadioButton2" text="RadioButton2" location="114,46" size="100,20" checked="True" groupname="example" />
        <input type="radio" name="RadioButton3" text="RadioButton3" location="212,46" size="100,20" font="Default,14.0" groupname="example" />
      </div>
      <div name="TabPage2" text="代码创建" type="tabpage" />
    </div>
  </body>
</html>
	"""
	renderFaceCat(gPaint, xml)
	#获取第二页
	tabPage = findViewByName("TabPage2", gPaint.views)
	radioButton = FCRadioButton()
	radioButton.location = FCPoint(100, 100)
	radioButton.size = FCSize(100, 20)
	addViewToParent(radioButton, tabPage)
	radioButton.text = "选项"

class AppDelegate(NSObject):
	def windowWillClose_(self, notification):
		os._exit(0)
	def applicationDidFinishLaunching_(self, notification):
		gPaint.size = FCSize(900, 770)
		window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(
		NSMakeRect(0, 0, gPaint.size.cx, gPaint.size.cy),
		15,
		NSBackingStoreBuffered,
		False
		)
		window.setDelegate_(self)
		window.orderFrontRegardless()
		view = FCUIView.alloc().initWithFrame_(NSMakeRect(0, 0, gPaint.size.cx, gPaint.size.cy))
		view.paint = gPaint
		window.setContentView_(view)
		gPaint.view = view
		loadUI()

app = NSApplication.sharedApplication()
delegate = AppDelegate.alloc().init()
app.setDelegate_(delegate)
app.run()
